package io.github.veigara.tcp.framework.event;

import com.google.common.eventbus.EventBus;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 设备事件总线
 */
@Component
public class DeviceEventBus {
    private final EventBus eventBus = new EventBus("device-event-bus");

    @PostConstruct
    public void init() {
        // 初始化事件总线
    }

    public void publishEvent(DeviceEvent event) {
        eventBus.post(event);
    }

    public void registerListener(Object listener) {
        eventBus.register(listener);
    }

    public void unregisterListener(Object listener) {
        eventBus.unregister(listener);
    }
}

